package heima3_2.cn.osc.ui.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import net.oschina.app.R;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import heima3_2.cn.osc.constant.Constants;
import heima3_2.cn.osc.model.bean.EventBean;
import heima3_2.cn.osc.model.bean.ExploreEventBean;
import heima3_2.cn.osc.ui.main_fragment.event_particulars_fragment.EventRecentFragment;
import heima3_2.cn.osc.ui.main_fragment.event_particulars_fragment.ExeriseRecentFragment;
import heima3_2.cn.osc.utils.PreferencesUtils;

/**
 * Created by Administrator on 2017/1/18 0018.
 */
public class EventprehensiveActivity extends AppCompatActivity {
    @Bind(R.id.btn_back)
    ImageButton mBtnBack;
    @Bind(R.id.tv_title)
    TextView mTvTitle;
    @Bind(R.id.iv_refresh)
    ImageView mIvRefresh;
    @Bind(R.id.tv_event_title)
    TextView mTvEventTitle;
    @Bind(R.id.tv_state_time)
    TextView mTvStateTime;
    @Bind(R.id.tv_end_time)
    TextView mTvEndTime;
    @Bind(R.id.tv_spot)
    TextView mTvSpot;
    @Bind(R.id.fl_event)
    FrameLayout flEvent;
    @Bind(R.id.iv_write)
    ImageView mIvWrite;
    @Bind(R.id.et_inpute)
    EditText mEtInpute;
    @Bind(R.id.iv_expression)
    ImageView mIvExpression;
    @Bind(R.id.iv_return)
    ImageView mIvReturn;
    @Bind(R.id.ll_comptehen_but)
    LinearLayout mLlComptehenBut;
    @Bind(R.id.iv_keyboard_input)
    ImageView mIvKeyboardInput;
    @Bind(R.id.iv_comment)
    ImageView mIvComment;
    @Bind(R.id.iv_input)
    ImageView mIvInput;
    @Bind(R.id.iv_like)
    ImageView mIvLike;
    @Bind(R.id.iv_share)
    ImageView mIvShare;
    @Bind(R.id.iv_warn)
    ImageView mIvWarn;
    @Bind(R.id.ll_comptehen_top)
    LinearLayout mLlComptehenTop;
    @Bind(R.id.fl_comptehen)
    FrameLayout mFlComptehen;
    private int event_recent;
    private int mEvent_recent;
    private ExploreEventBean.EventBean mEventBean;
    int EVENT_RECENT=1;
    int EVENT_EXERISE=2;
    private EventBean mExerise;
    private int mEvent_exerise;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_event_prehensive);
        ButterKnife.bind(this);
        iniData();
        iniPageData();
    }
    private void iniPageData() {
        Fragment fragment = null;
        if (mEvent_recent == EVENT_RECENT) {
            mTvTitle.setText("活动详情");
            mTvEventTitle.setText(mEventBean.getTitle());
            mTvStateTime.setText(mEventBean.getStartTime());
            mTvEndTime.setText(mEventBean.getEndTime() + "");
            mTvSpot.setText(mEventBean.getSpot());
            fragment =new EventRecentFragment();
          /*  int id = mEventBean.getId();
            System.out.println("id" + id);*/
            PreferencesUtils.setInt(getApplicationContext(), Constants.RECENT_ID, mEventBean.getId());
        }else if(mEvent_exerise==EVENT_EXERISE){
            mTvTitle.setText("活动详情");
            mTvEventTitle.setText(mExerise.getTitle());
            mTvStateTime.setText(mExerise.getStartTime());
            mTvEndTime.setText(mExerise.getEndTime() + "");
            mTvSpot.setText(mExerise.getSpot());
            fragment =new ExeriseRecentFragment();
            PreferencesUtils.setInt(getApplicationContext(), Constants.EXERISE_ID, mExerise.getId());
        }
        FragmentTransaction trans = getSupportFragmentManager()
                .beginTransaction();
        trans.replace(R.id.fl_event, fragment);
        trans.commitAllowingStateLoss();
    }
    private void iniRecentData() {
        Bundle bundle = getIntent().getExtras();
        mEventBean = (ExploreEventBean.EventBean) bundle.get("RECENT");
        mEvent_recent = getIntent().getIntExtra("EVENT_RECENT", 0);
    }
    private void iniExeriseData() {
        Bundle bundle = getIntent().getExtras();
        mExerise = (EventBean) bundle.get("EXERISE");
        mEvent_exerise = getIntent().getIntExtra("EVENT_EXERISE", 0);
    }
    private void iniData() {
        iniRecentData();
        iniExeriseData();
    }
    @OnClick({R.id.btn_back, R.id.iv_write, R.id.iv_expression, R.id.iv_return, R.id.ll_comptehen_but, R.id.iv_keyboard_input, R.id.iv_comment, R.id.iv_input, R.id.iv_like, R.id.iv_share, R.id.iv_warn})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.btn_back:
                finish();
                break;
            case R.id.iv_write:
                break;
            case R.id.iv_expression:
                break;
            case R.id.iv_return:
                break;
            case R.id.ll_comptehen_but:
                break;
            case R.id.iv_keyboard_input:
                break;
            case R.id.iv_comment:
                break;
            case R.id.iv_input:
                break;
            case R.id.iv_like:
                break;
            case R.id.iv_share:
                break;
            case R.id.iv_warn:
                break;
        }
    }
}
